package com.kun.video.domain;

import com.kun.video.ui.control.button.KunButton;
import com.kun.video.util.ChooserUtil;
import com.kun.video.util.ComUtil;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * TODO
 *
 * @author gzc
 * @since 2025/5/30
 **/
public class VideoDataStaticContext {
    private static final Logger log = LoggerFactory.getLogger(VideoDataStaticContext.class);

    public static final ObjectProperty<KunFileWrapper> SELECT_FILE = new SimpleObjectProperty<>();

    public static final KunButton SELECT_VIDEO_BUTTON = new KunButton("选择视频", "选择视频");

    /**
     * 选择视频文件
     */
    private static final Runnable SELECT_VIDEO_EVENT_HANDLER = () -> ComUtil.uiThreadRun(() -> {
        File file = ChooserUtil.showFile("选择视频", ChooserUtil.FileFormat.VIDEO);
        if (file != null) {
            SELECT_FILE.set(new KunFileWrapper(file));
        }else {
            log.warn("未选择文件");
        }
    });

    static {
        SELECT_VIDEO_BUTTON.action(SELECT_VIDEO_EVENT_HANDLER);
    }
}
